<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj = {
            name:"jack",
            age:30
        }
        console.log(obj.name);
        console.log(obj["age"]);

        let key = "name";
        console.log(obj[key]);//obj["name"]

        // ES5
        let obj2 = {

        }

        obj2[key] = "robin";
        console.log(obj2);

        // ES6属性名表达式
        let obj3 = {
            [key]:"rose",
            key:"hello"
        }

        // 对象的属性名 数据类型是 字符串 以及symbol（ES6新增数据类型）
        let num = 5;

        function fn(){

        }
        console.log(fn());

        function fn1(){

        }
        console.log(fn1())

        let obj4 = {
            [1+1]: 'hello',
            [Date.now()]: 'time',
            [num > 5? 'true':'false']: 'num',
            [obj]: 'function',
            [function(){}]: 'function',
            [undefined]: 'undefined',

            [fn()]:"good!",
            [fn1()]:"world!"
        }
        console.log(obj4);

    </script>
</body>
</html>